package pkgBFPaint;

import java.awt.Graphics;
import java.awt.Point;
import java.awt.Color;

public class DrawLine extends Action {

	private Point from, to;

	DrawLine(Color _color) {
		color = _color;
		actionID = ActionID.DRAWLINE;
	}

	DrawLine() {
		actionID = ActionID.DRAWLINE;
	}

	public void draw(Graphics g) {

		int i;

		g.setColor(color);

		if (points == null) {
			return;
		}

		from = points.getFirst();

		for (i = 1; i < points.size(); i++) {
			to = points.get(i);

			g.drawLine(from.x, from.y, to.x, to.y);

			from = to;
		}

	}
	/*
	 * public void draw(Graphics g) {
	 * 
	 * g.setColor(color);
	 * 
	 * if( points == null ) { return; }
	 * 
	 * pointsList = points.listIterator(); if( pointsList == null ) { return; }
	 * 
	 * while( pointsList.hasPrevious() ){ pointsList.previous(); }
	 * 
	 * if( pointsList.hasNext()) from = pointsList.next();
	 * 
	 * while( pointsList.hasNext() ) { to = pointsList.next(); g.drawLine(
	 * from.x , from.y , to.x , to.y ); from=to; }
	 *  }
	 */

}